package com.xiaweizi.transitiondemo.activity;

import android.app.ActivityOptions;
import android.content.Intent;
import android.os.Bundle;
import android.util.Pair;
import android.view.View;

import com.xiaweizi.transitiondemo.R;

import androidx.appcompat.app.AppCompatActivity;

public class TransitionHomeActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_transition_home);
        initListener();
    }

    private void initListener() {
        findViewById(R.id.home_transition1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(TransitionHomeActivity.this, TransitionOneActivity.class), ActivityOptions.makeSceneTransitionAnimation(TransitionHomeActivity.this).toBundle());
            }
        });
        findViewById(R.id.home_transition2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(TransitionHomeActivity.this, TransitionTwoActivity.class), ActivityOptions.makeSceneTransitionAnimation(TransitionHomeActivity.this).toBundle());
            }
        });
        findViewById(R.id.home_transition3).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(TransitionHomeActivity.this, TransitionThreeActivity.class), ActivityOptions.makeSceneTransitionAnimation(TransitionHomeActivity.this).toBundle());
            }
        });

        final View image = findViewById(R.id.image_blue);
        final View text1 = findViewById(R.id.text1);
        findViewById(R.id.home_transition4).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Pair pair = new Pair(image, image.getTransitionName());
                Pair pair1 = new Pair(text1, text1.getTransitionName());
                startActivity(new Intent(TransitionHomeActivity.this, ShareElementActivity.class), ActivityOptions.makeSceneTransitionAnimation(TransitionHomeActivity.this, pair, pair1).toBundle());
            }
        });
    }

}
